﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section header{

}

<body>
    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form" action="" lay-filter="example">
                <div class="layui-form-item">
                    <input type="text" name="runValue" class="layui-input" placeholder="输入最后执行的值">
                </div>

                <div class="layui-form-item" style="text-align: center;">
                    <button class="layui-btn" lay-submit="" lay-filter="save">保存</button>
                    <button type="button" class="layui-btn layui-btn-primary" function="close">关闭</button>
                </div>
            </form>
        </div>
    </div>
</body>

<script>
        layui.use(['form'], function () {
            var form = layui.form;

            var taskId = common.getUrlParam("taskId");

            request.ajax({
                type: "get",
                url: "/Schedule/GetTaskById?id=" + taskId,
                success: function (data) {
                    if (data.success) {
                        form.val('example', {
                            "runValue": data.data.runValue
                        })
                    }
                    else {
                        common.errorMsg(data.message);
                    }
                }
            });

            $("[function='close']").click(function () {
                common.closeOpen();
            });

            form.on('submit(save)', function (data) {
                request.ajax({
                    type: "post",
                    url: "/Schedule/UpdateRunValue",
                    data: { id: taskId, runValue: data.field.runValue },
                    success: function (data) {
                        if (data.success) {
                            $('#isReload', window.parent.document).val("1");
                            common.closeOpen();
                        }
                        else {
                            common.errorMsg(data.message);
                        }
                    }
                });

                return false;
            });
        });
</script>